package top.laoshuzi.common.utils.pojo.page;

import java.util.ArrayList;

import top.laoshuzi.common.utils.pojo.Mapper;

public class PageMapper<T extends Mapper<M>, M> extends Page<T> implements Mapper<Page<M>> {

    @Override
    public Page<M> map() {
        Page<M> mPage = new Page<>();
        mPage.setContent(new ArrayList<M>());
        for (T t : getContent())
            mPage.getContent().add(t.map());
        mPage.setFirst(isFirst());
        mPage.setLast(isLast());
        mPage.setNumber(getNumber());
        mPage.setNumberOfElements(getNumberOfElements());
        mPage.setSize(getSize());
        mPage.setTotalElements(getTotalElements());
        mPage.setTotalPages(getTotalPages());
        return mPage;
    }

}
